package com.andy.qhb.controller;

import javax.servlet.http.HttpSession;

import com.andy.qhb.game.GameUser;
import com.andy.qhb.game.GlobalHttp;
import com.andy.qhb.utils.GoConstant;

public class GameController {

	public GameUser getUser(HttpSession session){
		Long uid = (Long) session.getAttribute(GoConstant.USER_SESSION_KEY);
		if(uid == null){
			throw new RuntimeException("登录超时");
		}
		GameUser user = GlobalHttp.getUser(uid);
		if(user == null){
			throw new RuntimeException("登录超时");
		}
		return user;
	}
	
	public GameUser getUserSafe(HttpSession session){
		Long uid = (Long) session.getAttribute(GoConstant.USER_SESSION_KEY);
		if(uid == null){
			return null;
		}
		return GlobalHttp.getUser(uid);
	}
	
}
